//从pinia中引入defineStore
import { defineStore } from "pinia";
//从封装的请求列表的接口引入
import { userList, trading, profit, orderList } from "@/api/userList";
// useStore 可以是 useUser、useCart 之类的任何东西
// 第一个参数是应用程序中 store 的唯一 id
export const userlist = defineStore("userlist", {
  state: () => {
    return {
      //存储的数据存放位置
      userlist: [], //用户列表
      tradinglist: [], //交易记录
      profitlist: [], //分润记录
      orderListlsit: [] //订单列表
    };
  },
  actions: {
    //用户列表
    async getList() {
      const that = this;
      const data = await userList();
      that.userlist = data.data.data;
      return data.data.data;
    },
    //交易记录
    async getTradingList() {
      const that = this;
      const data = await trading();
      that.tradinglist = data.data.data;
      return data.data.data;
    },
    //分润记录
    async getProfitList() {
      const that = this;
      const data = await profit();
      that.profitlist = data.data.data;
      return data.data.data;
    },
    //订单列表
    async getorderList() {
      const that = this;
      const data = await orderList();
      that.orderListlsit = data.data.data;
      return data.data.data;
    }
  }
});
